f()
function f() {
    if (loginCustomer==null||loginCustomer===""){
        alert("请去登录")
        location.href="http://localhost:8080/customer/login.jsp";
    }
}

//退出登录
$(".out-login").click(function () {
    console.log("ssss")
    $.ajax({
        type:"get",
        url: "../outLogin",
        success: function (result) {
            console.log("result:" + result);

            location.href = "http://localhost:8080/index.jsp";

        }

    })
})


getCustImg()
//得到照片url
function getCustImg() {
    $.ajax({
        type: "get",
        // contentType: "application/json",
        // data:
        //     `{"number":${number}}`
        // `{"numberPwd":${numberPwd}}`
        // ,
        // dataType: "json",
        url: "../getCustImg",
        success: function (result) {
            // console.log("result:" + result);
            if (result===null||result===""){

            }else {
                var custImgUrl = document.getElementById("image");
                custImgUrl.src= result
                // console.log(custImgUrl)
            }

            // var pwd = result.data;
            // if (result.code === 200){
            //     if (pwd===numberPwd){
            //         location.href = "http://localhost:8080/index.jsp";
            //     }else {
            //         alert("账号或密码错误");
            //     }
            // }
            // else
            //     alert(result.data);
        }
    })
}



findByCityName()

var hotelId;
function findByCityName() {
    console.log(typeof (cityName))
    console.log(cityName)
    $.ajax({
        type:"post",
        contentType: "application/json",
        data:
        cityName
        // `{"numberPwd":${numberPwd}}`
        ,
        // dataType: "json",
        url: "../getByCity",
        success: function (result) {
            console.log(result)
            if (result===null||result===""){
                alert("请先登录")
            }else {
                var hotels = result.data
                 console.log(hotels)
                var ulEle = document.querySelector(".body-context-ul")
                console.log(ulEle)
                for (var i=0;i<hotels.length;i++){
                    // console.log(hotels[i].hotelId)
                    var hotelImg = hotels[i].other2
                    var hotelName = hotels[i].hotelName
                    var hotelPrice = hotels[i].other1
                    var hotelScroe = hotels[i].hotelScroe
                    var newli = "<li>\n" +
                        "                    <div class=\"body-context-image\">\n" +
                        "                        <a href=\"javascript:;\"><img src='"+hotelImg+"'/></a>\n" +
                        "                    </div>\n" +
                        "                    <div class=\"body-context-second-c\">\n" +
                        "                        <span><a href=\"javascript:;\" class=\"hotel_title\">"+hotelName+"</a></span>\n" +
                        "                        <span></span>\n" +
                        "                        <span style=\"font-family: 'Adobe 黑体 Std R'\">豪华双人间-禁烟</span>\n" +
                        "                        <span>2张单人床</span>\n" +
                        "                        <span style=\"color: #3e8f3e;font-family: 'Bauhaus 93'\">免费取消</span>\n" +
                        "                        <span style=\"color: #3e8f3e;font-family: 'Bauhaus 93'\">预订无忧：计划有变可取消,锁定好价趁现在</span>\n" +
                        "                    </div>\n" +
                        "                    <div class=\"body-context-third-c\">\n" +
                        "                        <span style=\"position: relative;left:190px;font-family: 'Adobe 黑体 Std R'\"><span>评分: </span><span>" + hotelScroe + "</span></span><br>\n" +
                        "                        <span style=\"position: relative;left:165px;\">1晚, 2位成人</span><br>\n" +
                        "                        <span style=\"position: relative;left:175px;font-family: 'Adobe 黑体 Std R';font-size: 18px\"><span>"+hotelPrice+"</span><span>元起</span></span><br>\n" +
                        "                        <span style=\"position: relative;left:114px;\">+155元税费及其他费用</span><br>\n" +
                        "                        <button class='goHotel'>选择客房</button>\n" +
                        "                    </div>\n" +
                        "                </li>"
                    ulEle.innerHTML+=newli
                }
            }
        }
    })
}

$("body").on("click",".hotel_title",function () {
    var hotelName = $(this).text();
    console.log(hotelName)
    $.ajax({
        type:"post",
        contentType: "application/json",
        data: hotelName,
        dataType: "json",
        url: "../getSession",
        success: function (result) {
            if (result===null||result===""){
                alert("请先登录")
            }else {
                 location.href = "http://localhost:8080/hotel/hotel_detail.jsp";
            }
        }
    })
})







